package com.xqc.spi;

import java.util.Iterator;
import java.util.ServiceLoader;
public class SpiTest {

	
	public static void main(String[] args) {
		//ServiceLoader.load方式
		load();
		
	}

	private static void load() {
		ServiceLoader<PrinterService> serviceLoaders = ServiceLoader.load(PrinterService.class);
		Iterator<PrinterService> iterator = serviceLoaders.iterator();
		while(iterator.hasNext()){
			iterator.next().printer();
		}
	}
	
}
